﻿'Copyright 2010 Brian L. Crawford

'Licensed under the Apache License, Version 2.0 (the "License");
'you may not use this file except in compliance with the License.
'You may obtain a copy of the License at

'    http://www.apache.org/licenses/LICENSE-2.0

'Unless required by applicable law or agreed to in writing, software
'distributed under the License is distributed on an "AS IS" BASIS,
'WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'See the License for the specific language governing permissions and
'limitations under the License.

'This software uses Microsoft .Net framework used with permission from      
'Microsoft. Microsoft, .Net Framework, Visual Studio, Visual Basic, Visual C++ 
'remain the trademark and copyright of Microsoft and are subject to their 
'individual licenses.


Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Drawing.Text
Imports System.Drawing
Public Class Form2
    Public Sub content_locations()
        Dim H, W, w2 As Integer
        H = Me.Height()
        W = Me.Width()
        w2 = W / 2
        'bounding box size (74 + 74 + 98) + 12 wide x 22 high
        'buttons don't place themselves correctly
        'cetner button3
        Button3.Size = New Size(98, 22)
        Button3.Left = w2 - (Button3.Width / 2) 'size = 98w x 22h
        Button3.Top = H - Button3.Height - 40
        Button1.Size = New Size(74, 22)
        Button1.Left = Button3.Left - 6 - Button1.Width  'size = 74w x 22h 'align left of button3
        Button1.Top = H - Button3.Height - 40
        Button2.Size = New Size(74, 22)
        Button2.Left = Button3.Left + Button3.Width + 6  'size = 74w x 22h 'align right of button3
        Button2.Top = H - Button3.Height - 40
        ListBox1.Left = 4
        ListBox1.Top = 4
        ListBox1.Height = H - (H - Button1.Top) - 20
        ListBox1.Width = w2 - 4
        ListBox2.Left = w2 + 4
        ListBox2.Top = 4
        ListBox2.Height = H - (H - Button1.Top) - 20
        ListBox2.Width = w2 - 8
    End Sub
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        content_locations()
        Button2.Enabled = False 'change this once the new code has been implemented 
        Button3.Enabled = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.BackgroundWorker1.CancelAsync()
        Form1.BackgroundWorker2.CancelAsync()
        Form1.BackgroundWorker3.CancelAsync()
        'add code to clear previous variable and classes
    End Sub

    Private Sub Form2_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        content_locations()
    End Sub

    Private Sub ListBox1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Disposed

    End Sub

    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim fc As String
        'Dim fs2 As Collection
        'fs2 = Form1.folder2.do_Files()
        fc = "The Reference folder is " & Form1.Path() & vbCrLf & "The following files in this folder don't seem to match files found in the reference folder: " & vbCrLf & vbCrLf
        For Each fn3 In ListBox2.Items
            fc = fc & fn3 & vbCrLf
        Next
        WriteLog((fc), Form1.Path())
        Form1.resetfolderstatus() 'don't clear the lists here, someone might want to save the result a couple of times
    End Sub

    Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        CompareFiles(ListBox1, ListBox2, ListBox2.Items.Count - 1)
        'Form1.resetfolderstatus()
    End Sub
End Class
